06. Exercise: Create and Register a ContentProvider

Create and Register a ContentProvider

Create and Register Your Provider

These steps will have you build and register a custom content provider.

Exercise Code

Exercise: T09.01-Exercise-SetupContentProvider

In TaskContentProvider complete the TODOs.

SOLUTION:
  • Check that TaskContentProvider extends from the abstract ContentProvider class and implements required functions
  • Complete the onCreate method by initializing a TaskDbHelper (Don’t forget to declare this helper as a global variable)

In the AndroidManifest register your content provider by following the TODOs.

SOLUTION:
  • Add a tag in your Android manifest file
  • Set the name, authority, and exported attributes (android:name, android:authorities, android:exported)